// #include "edgesBase.hpp"
// #include "meshBase.hpp"
// #include "edges.hpp"
#include "boundaryPatch.hpp"

namespace hms
{

#define EHEAD(RETURN_TYPE) \
template<typename EdgesType> \
RETURN_TYPE EdgesBase<EdgesType>::

EHEAD()
EdgesBase( const MeshBase<MeshType>& meshArg ){
	mesh( meshArg.derived() );
}

EHEAD(auto) mesh() const -> const MeshType& {
	assert( m_mesh && "Dereferencing nullptr!" );
	return *m_mesh;
}
EHEAD(void) mesh( const MeshType& meshArg ){
	// assert( !m_mesh && "EdgesBase already has a mesh assigned to it!" );
	m_mesh = std::experimental::make_observer( &meshArg );
}

EHEAD(auto) outwardNormals( const BoundaryPatch& patch ) const -> decltype(auto) {
	return patch.outwardNormals( mesh() );
}

#define FORWARD_FUNC_NOARG(NAME,RET) \
EHEAD(auto) NAME() const -> RET { \
	return this->derived().NAME##Imp(); \
}

#define FORWARD_FUNC_INDEX(NAME,RET) \
EHEAD(auto) NAME(Index i) const -> RET { \
	return this->derived().NAME##Imp(i); \
}

#ifdef STRUCTMESH_PRECALC_EDGE_PARENT_CELLS
FORWARD_FUNC_INDEX(cells, const Array2Xi&)
#endif

FORWARD_FUNC_NOARG(lengths, LengthsReturnType)
FORWARD_FUNC_NOARG(normals, NormalsReturnType)


#undef FORWARD_FUNC_INDEX
#undef FORWARD_FUNC_NOARG
#undef EHEAD

// template class EdgesBase<Edges>;
// template class EdgesBase<StructEdgesBase>;

} // namespace hms
